// Package consts
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2023 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts

import (
	"hotgo/internal/library/dict"
	"hotgo/internal/model"
)

func init() {
	dict.RegisterEnums("creditType", "资金变动类型", CreditTypeOptions)
	dict.RegisterEnums("creditGroup", "资金变动分组", CreditGroupOptions)
}

const (
	CreditTypeBalance  = "balance"  // 余额
	CreditTypeIntegral = "integral" // 积分
)

const (
	CreditGroupDecr             = "decr"              // 扣款
	CreditGroupIncr             = "incr"              // 加款
	CreditGroupDistributionIncr = "distribution_incr" // 分销加款
	CreditGroupOpDecr           = "op_decr"           // 操作扣款
	CreditGroupOpIncr           = "op_incr"           // 操作加款
	CreditGroupBalanceRecharge  = "balance_recharge"  // 余额充值
	CreditGroupBalanceRefund    = "balance_refund"    // 余额退款
	CreditGroupApplyCash        = "apply_cash"        // 申请提现
)

// 根据类型获取对应的变动分组
// typeint 0 所有 1 加款 2 扣款
func GetCreditGroup(typeint int) []string {
	switch typeint {
	case 0:
		return append(CreditIncr, CreditDecr...)
	case 1:
		return CreditIncr
	case 2:
		return CreditDecr
	default:
		return []string{}
	}
}

// 根据类型获取用户钱包对应的变动分组
// typeint 0 所有 1 加款 2 扣款
func GetUserCreditGroup(typeint int) []string {
	switch typeint {
	case 0:
		return append(UserCreditIncr, UserCreditDecr...)
	case 1:
		return UserCreditIncr
	case 2:
		return UserCreditDecr
	default:
		return []string{}
	}
}

// 加款
var CreditIncr = []string{
	CreditGroupIncr,
	CreditGroupOpIncr,
	CreditGroupBalanceRecharge,
	CreditGroupBalanceRefund,
	CreditGroupDistributionIncr,
}

// 扣款
var CreditDecr = []string{
	CreditGroupDecr,
	CreditGroupOpDecr,
	CreditGroupApplyCash,
}

// 用户钱包加款
var UserCreditIncr = []string{
	CreditGroupBalanceRefund,
}

// 用户钱包扣款
var UserCreditDecr = []string{
	CreditGroupApplyCash,
}

// CreditTypeOptions 变动类型
var CreditTypeOptions = []*model.Option{
	dict.GenSuccessOption(CreditTypeBalance, "余额"),
	dict.GenInfoOption(CreditTypeIntegral, "积分"),
}

// CreditGroupOptions 变动分组
var CreditGroupOptions = []*model.Option{
	dict.GenWarningOption(CreditGroupDecr, "扣款"),
	dict.GenSuccessOption(CreditGroupIncr, "加款"),
	dict.GenWarningOption(CreditGroupOpDecr, "操作扣款"),
	dict.GenSuccessOption(CreditGroupOpIncr, "操作加款"),
	dict.GenWarningOption(CreditGroupBalanceRefund, "余额退款"),
	dict.GenSuccessOption(CreditGroupBalanceRecharge, "余额充值"),
	dict.GenInfoOption(CreditGroupApplyCash, "申请提现"),
	dict.GenInfoOption(CreditGroupDistributionIncr, "分销加款"),
}
